#include "LogicNotNode.h"
#include "..\Common\AssertHelper.h"

using namespace std;

namespace CExpression
{
	void LogicNotNode::Eval(ExecuteContext &context)
	{
		this->child->Eval(context);
		if(AssertHelper::ExpectType(context.TempResultType(),ExecuteRunTimeType::Double,context,TEXT("Logic-not operator's operand must be double type.")))
		{
			context.SetGlobalTempNum(~static_cast<int>(context.GlobalTempNum()));
			context.SetTempResultType(ExecuteRunTimeType::Double);
		}
	}

	shared_ptr<Node> LogicNotNode::Clone(Expression &parent)
	{
		shared_ptr<Node> result(new LogicNotNode(this->child->Clone(parent)));
		return result;
	}
}